import React from 'react';
import cx from 'classnames';
import S from './index.m.less';

export default class Table extends React.PureComponent {
    static defaultProps = {
        className: '',
        href: '',
        left: {
            name: '',
            className: '',
        },
        right: {
            name: '',
            className: '',
        },
        showArrow: true,
        line: {
            hide: false, // 隐藏下拉线
            className: '', // 配置线的颜色
        },
        icon: '',
        paddingLeft: '0.32rem',
    };

    render() {
        const {
            className, left, right, icon, showArrow, line, href, paddingLeft
        } = this.props;
        return (
            <Link className={cx(S.table, className)} href={href}>
                <div className={S.menu} style={{ padding: `0 ${paddingLeft}` }}>
                    <span className={cx(S.left, left.className)}>
                        <i className={S.icon} style={{ backgroundImage: `url(${icon})` }} />
                        <span>{left.name}</span>
                    </span>
                    <span className={cx(S.right, right.className)}>
                        {right.name}
                        {showArrow && <i className="wptFM icon-fm-arrowright" />}
                    </span>
                </div>
                {!line.hide && (
                    <div className={cx(S.line, line.className)} style={{ paddingLeft }}>
                        <p />
                    </div>
                )}
            </Link>
        );
    }
}
